package base_demo.giftDemo;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Myrungift implements Runnable{
    static int gift = 100;
    static Lock lock = new ReentrantLock();//之呢个公用一把锁
    @Override
    public void run() {
        while(true){
            lock.lock();{
                if(gift  == 10 ){
                    return;
                }

                System.out.println(Thread.currentThread().getName() +"送出了第" + gift + "个礼品!!!");
                gift--;

            }
            lock.unlock();


        }
    }
}
